package com.sapdroid.sapdroiddo;

import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.sapdroid.sapdroiddo.content.TodoListTable;

public class ActionBarSpinnerCursorAdapter extends CursorAdapter {
	private final LayoutInflater inflater;

	public ActionBarSpinnerCursorAdapter(Context context, Cursor c, boolean autoRequery) {
		super(context, c, autoRequery);
		inflater = LayoutInflater.from(context);
	}

	@Override
	public void bindView(View view, Context context, Cursor cursor) {
		TextView textView = (TextView) view.findViewById(android.R.id.text1);
		if (textView != null) {
			textView.setText(cursor.getString(cursor
					.getColumnIndex(TodoListTable.COLUMN_DESCRIPTION)));
			textView.setSingleLine();
			textView.setTextColor(context.getResources()
					.getColor(R.color.orange));
			textView.setTag(cursor.getString(cursor
					.getColumnIndex(TodoListTable.COLUMN_ID)));
		}
	}

	@Override
	public View newView(Context arg0, Cursor arg1, ViewGroup arg2) {
		View view = inflater
				.inflate(android.R.layout.simple_list_item_1, arg2, false);
		return view;
	}

}